package com.maizhe.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maizhe.dao.CustomerDrainsMapper;
import com.maizhe.dao.CustomerMapper;
import com.maizhe.entity.Customer;
import com.maizhe.entity.CustomerDrains;
import com.maizhe.entity.vo.UserVo;
import com.maizhe.service.CustomerDrainsService;
import com.maizhe.service.CustomerService;
import com.maizhe.util.UUIDGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CustomerDrainsServiceImpl implements CustomerDrainsService {

	@Autowired
	private CustomerDrainsMapper customerDrainsMapper;

	/*找所有流失的用户*/
	public PageInfo<CustomerDrains> findAll(CustomerDrains customerDrains) {
		PageHelper.startPage(customerDrains.getPage(),customerDrains.getRows());
		List<CustomerDrains> list=customerDrainsMapper.findAll(customerDrains);
		return new PageInfo<CustomerDrains>(list);
	}

	public int waitDrains(String id) {
		CustomerDrains customerDrains=new CustomerDrains();
		customerDrains.setId(id);
		customerDrains.setStatus("暂缓流失");
		return customerDrainsMapper.updateCustomerDrains(customerDrains);
	}

	public int okDrains(CustomerDrains customerDrains) {
		customerDrains.setStatus("确定流失");
		customerDrains.setDrainDate(new Date());
		return customerDrainsMapper.updateCustomerDrains(customerDrains);
	}

	public CustomerDrains findById(String id) {
		return customerDrainsMapper.findById(id);
	}


}
